package com.fsp.controller;

import com.fsp.pojo.Superman;
import com.fsp.service.SupermanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author fushengping
 * @className SupermanController
 * @description
 * @date 2021/11/30 9:33
 */
@RestController
public class SupermanController {

    //SupermanService三种全量递归查询树形结构
    @Autowired
    private SupermanService supermanService;

    /**
     *  法一：递归，多次查询数据库，效率太低
     * @return
     */
    @RequestMapping("/superman1")
    public List getSuperman1() {
        return supermanService.getSupermanAll1();
    }

    /***
         * 法二：循环读取设置
     * @return
     */
    @RequestMapping("/superman2")
    public List getSuperman2() {
        return supermanService.getSupermanAll2();
    }

    /***
     * 法二：map集合读取设置
     * @return
     */
    @RequestMapping("/superman3")
    public List getSuperman3() {
        return supermanService.getSupermanAll3();
    }

    /**
     * 根据pid分步查询（实际开发最常用）
     * @param pid
     * @return
     */
    @RequestMapping("getSupermanByPid")
    public List getSupermanByPid(Integer pid) {
        List<Superman> list = supermanService.getSupermanByPid(pid);
        return list;
    }
}
